public class main {

    public static void main(String[] args) {
        int[] A = {1,2,3,4};
        numberOfArithmeticSlices(A);
    }

    public static int numberOfArithmeticSlices(int[] A) {
        int sum = 0;
        int count=0;
        for(int i=2;i<A.length;i++){
            if(A[i]-A[i-1]==A[i-1]-A[i-2]){
                count++;
                if(i==A.length-1){
                    sum += (count+1)*count/2;
                }
            }else{
                sum += (count+1)*count/2;
                count=0;
            }
        }
        return sum;
    }
}
